package com.itruth.data.entity;

import com.itruth.data.preference.ItruthPref;

/**
 * 存放当前用户的个人信息
 * 未登录时，则只存放与登录无关的信息
 * @author yj
 *
 */
public class UserData {
	
	private static UserData instance = new UserData();
	
	/**
	 * 用户名
	 */
	private String userName;
	
	/**
	 * 已经执笔次数
	 */
	private int writeTimes = -1;
	
	/**
	 * 当前用户查看的分享数据最小索引
	 */
	private int shareMinId = -1;
	
	private UserData() {
		
	}
	
	public static UserData getIns() {
		return instance;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public int getWriteTimes() {
		
		if (writeTimes < 0) {
			writeTimes = ItruthPref.getIns().getWriteTimes();
		}
		
		return writeTimes;
	}

	public void setWriteTimes(int writeTimes) {
		this.writeTimes = writeTimes;
		
		ItruthPref.getIns().setWriteTimes(writeTimes);
		
	}
	
	public void setShareMinId(int shareMinId) {
		this.shareMinId = shareMinId;
		ItruthPref.getIns().setShareMinId(shareMinId);
	}
	
	public int getShareMinId() {
		
		if (shareMinId < 0) {
			shareMinId = ItruthPref.getIns().getShareMinId();
		}
		
		return shareMinId;
	}
}
